Add Skip.Test() documentation for dynamic test skipping#4018
Conversation
…ipping Co-authored-by: thomhurst <30480171+thomhurst@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive documentation for dynamic test skipping at runtime using the Skip.Test() API and its variants (Skip.When(), Skip.Unless()), addressing a gap in the existing skip documentation.
Key Changes
- Added a new "Dynamic Skipping at Runtime" section explaining when and how to use
Skip.Test(reason)for runtime test skipping - Documented conditional skip helpers
Skip.When()andSkip.Unless()with practical examples - Provided examples of using skip methods in test hooks (
Before(Test)andBefore(Class))
| [Test] | ||
| public void Test1() | ||
| { | ||
| // This test will be skipped if database is unavailable |
There was a problem hiding this comment.
Inconsistent punctuation in comment. The comment should end with a period for consistency with other comments in the documentation (e.g., line 93, 172, 206).
Suggested change:
// This test will be skipped if database is unavailable.| // This test will be skipped if database is unavailable | |
| // This test will be skipped if database is unavailable. |
| [Test] | ||
| public void Test2() | ||
| { | ||
| // This test will also be skipped if database is unavailable |
There was a problem hiding this comment.
Inconsistent punctuation in comment. The comment should end with a period for consistency with other comments in the documentation (e.g., line 93, 172, 206).
Suggested change:
// This test will also be skipped if database is unavailable.| // This test will also be skipped if database is unavailable | |
| // This test will also be skipped if database is unavailable. |
| [Test] | ||
| public void Test1() | ||
| { | ||
| // All tests in this class will be skipped if service is unavailable |
There was a problem hiding this comment.
Inconsistent punctuation in comment. The comment should end with a period for consistency with other comments in the documentation (e.g., line 93, 172, 206).
Suggested change:
// All tests in this class will be skipped if service is unavailable.| // All tests in this class will be skipped if service is unavailable | |
| // All tests in this class will be skipped if service is unavailable. |
|
|
||
| Skip.When(isCI, "This test doesn't run in CI environments"); | ||
|
|
||
| // Test continues only when not in CI |
There was a problem hiding this comment.
Inconsistent punctuation in comment. The comment should end with a period for consistency with other comments in the documentation (e.g., line 93, 172, 206).
Suggested change:
// Test continues only when not in CI.| // Test continues only when not in CI | |
| // Test continues only when not in CI. |
|
|
||
| Skip.Unless(hasRequiredPermissions, "User doesn't have required permissions"); | ||
|
|
||
| // Test continues only if user has permissions |
There was a problem hiding this comment.
Inconsistent punctuation in comment. The comment should end with a period for consistency with other comments in the documentation (e.g., line 93, 172, 206).
Suggested change:
// Test continues only if user has permissions.| // Test continues only if user has permissions | |
| // Test continues only if user has permissions. |
Please check the following before creating a Pull Request
Description
The skipping documentation was missing coverage of
Skip.Test(reason)and its variants for runtime test skipping.Changes
Added comprehensive "Dynamic Skipping at Runtime" section to
docs/docs/test-authoring/skip.mdcovering:Skip.Test(reason)- Core method for dynamic skipping within test methods or hooksSkip.When(condition, reason)- Conditional skip when condition is trueSkip.Unless(condition, reason)- Conditional skip unless condition is trueBefore(Test)andBefore(Class)hooks[Skip]attributeExample
Documentation builds successfully with no errors.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.